/**
 * Filename: pr_exit.c
 * Author:   csbonkers
 * Contact:  csbonkers@mail.ynu.edu.cn
 * Date:     4/30/21
 * Description:
 *      打印exit状态说明
 */

#include "apue.h"
#include <sys/wait.h>

void pr_exit(int status) {
  if (WIFEXITED(status)) {
    printf("normal termination, exit status = %d\n", WEXITSTATUS(status));
  } else if (WIFSIGNALED(status)) {
    printf("abnormal termination, signal number = %d%s\n", WTERMSIG(status),
#ifdef WCOREDUMP
        WCOREDUMP(status) ?"(core file generated)":"");
#else
           "");
#endif
  }
  else if (WIFSTOPPED(status)){
    printf("child stopped, signal number %d\n", WSTOPSIG(status));
  }
}